package com.xxx.netty.inoutbound.client;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * client端业务处理器
 */
public class MyClientHandler extends SimpleChannelInboundHandler<Long> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Long msg) throws Exception {
        System.out.println("服务端地址：" + ctx.channel().remoteAddress());
        System.out.println("从服务端读取到数据, msg：" + msg);
    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        System.out.println("MyClientHandler.channelActive()被调用. 发送数据...");
        ctx.channel().writeAndFlush(12345L);
    }
}
